﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BZOrderPrint
{
    public partial class FrmSetPrinter : Form
    {
        private readonly string _faceSheetPrinterKey = "FaceSheetPrinter";

        private readonly string _paperPrinterKey = "PaperPrinter";

        public FrmSetPrinter()
        {
            InitializeComponent();
        }

        private void FrmSetPrinter_Load(object sender, EventArgs e)
        {
            PrintDocument print = new PrintDocument();
            List<string> list = new List<string>();
            foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称
            {
                comboBox1.Items.Add(sPrint);
                comboBox2.Items.Add(sPrint);
            }
            var faceSheetPrinterValue = ConfigHelper.GetAppSettingValue(_faceSheetPrinterKey);
            var paperPrinterValue = ConfigHelper.GetAppSettingValue(_paperPrinterKey);
            comboBox1.SelectedItem = faceSheetPrinterValue;
            comboBox2.SelectedItem = paperPrinterValue;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ConfigHelper.modifyConfig(_faceSheetPrinterKey, comboBox1.SelectedItem.ToString());
            ConfigHelper.modifyConfig(_paperPrinterKey, comboBox2.SelectedItem.ToString());
            Close();
        }
    }
}
